Unit BDijitContentPaneUnit;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, BDojoSessionUnit, BDijitWidgetUnit;

Type

{ BDijitContentPaneClass }

 BDijitContentPaneClass = Class(BDijitWidgetClass)
  Private
    bContent: String;
    bContentObj: BDijitWidgetClass;
    bDoLayout: Boolean;
    bExtractContent: Boolean;
    bHref: String;
    bPreload: Boolean;
    bTitle: String;
    Procedure SetContent(aValue: String);
    Procedure SetContentObj(aValue: BDijitWidgetClass);
    Procedure SetExtractContent(aValue: Boolean);
    Procedure SetHref(aValue: String);
    Procedure SetPreload(aValue: Boolean);
  Public
    //** The innerHTML of the ContentPane. Note that the initialization
    //** parameter / argument to set("content", ...) can be a String
    Property ContentString: String Read bContent Write SetContent;
    //** The innerHTML of the ContentPane. Note that the initialization
    //** parameter / argument to set("content", ...) can be a Widget.
    //** !associate when set
    Property ContentObj: BDijitWidgetClass Read bContentObj Write SetContentObj;
    //** false - don't adjust size of children - true - if there is a
    //** single visible child widget, set it's size to however big the
    //** ContentPane is
    Property DoLayout: Boolean Read bDoLayout Write bDoLayout;
    //** The href of the content that displays now. Set this at construction if
    //** you want to load data externally when the pane is shown.
    //** (Set preload=true to load it immediately.) Changing href after creation
    //** doesn't have any effect; Use set('href', ...);
    Property Href: String Read bHref Write SetHref;
    //** Extract visible content from inside of <body> .... </body>.
    //** I.e., strip <html> and <head> (and it's contents) from the href
    Property ExtractContent: Boolean Read bExtractContent
      Write SetExtractContent;
    //** Force load of data on initialization even if pane is hidden.
    Property Preload: Boolean Read bPreload Write SetPreload;

    //** returns If child has an href, promise that fires when refresh is
    //** complete [Re]download contents of href and display
    Procedure Refresh;

    Constructor Build(Const aSession: BDojoSessionClass;
      Const aJSType: String=''); Override;
    Destructor Burn; Override;
End;

Implementation

{ BDijitContentPaneClass }

Procedure BDijitContentPaneClass.SetContent(aValue: String);
Begin
  bContent := aValue;
  SetConfig('content', aValue);
End;

Procedure BDijitContentPaneClass.SetContentObj(aValue: BDijitWidgetClass);
Begin
  Associate(aValue);
  bContentObj := aValue;
  SetConfig('content', aValue.JSName, FALSE);
End;

Procedure BDijitContentPaneClass.SetExtractContent(aValue: Boolean);
Begin
  bExtractContent := aValue;
  SetConfig('extractContent', aValue);
End;

Procedure BDijitContentPaneClass.SetHref(aValue: String);
Begin
  bHref := aValue;
  SetConfig('href', aValue);
End;

Procedure BDijitContentPaneClass.SetPreload(aValue: Boolean);
Begin
  bPreload := aValue;
  SetConfig('preload', aValue);
End;

Procedure BDijitContentPaneClass.Refresh;
Begin
  AddAjax('refresh();');
End;

Constructor BDijitContentPaneClass.Build(Const aSession: BDojoSessionClass;
  Const aJSType: String);
Begin
  If aJSType = '' Then Inherited Build(aSession, 'dijit.layout.ContentPane')
  Else Inherited Build(aSession, aJSType);
End;

Destructor BDijitContentPaneClass.Burn;
Begin
  Inherited Burn;
End;

End.

